﻿LApp.service("CommonService", function ($log, $http, $lvl) {
    var self = this;
    this.CheckLogOn = function () {
        if (this.IsLogOn()) {
            window.location.href = "Main.html"
        }
    };
    this.CheckUnLogOn = function () {
        if (!this.IsLogOn()) {
            window.location.href = "LogOn.html"
        }
    };
    this.IsLogOn = function () {
        if (localStorage["L_U_T"]) return true;
        return false;
    };
    this.SetCurrentUser = function (_user) {
        localStorage["L_U_T"] = JSON.stringify(_user);
    }

    this.GetCurrentUser = function () {
        return JSON.parse(localStorage["L_U_T"]);
    }

    this.RemoveCurrentUser = function () {
        localStorage.removeItem("L_U_T");
    }

    this.ChangePassword = function (param) {
        $lvl.get(GlobalConfig.APIServer + "api/nbsys/changepassword",
            param.data,
            param.success
        );
    }
})

